package com.augurit.wf.client.opinion.convert;

import java.util.ArrayList;
import java.util.List;

import com.augurit.wf.bi.web.form.WfViewCustomConfigForm;
import com.augurit.wf.client.opinion.web.form.WfUserOpinionForm;
import com.augurit.wf.common.entity.WfUserOpinion;
import com.augurit.wf.common.entity.WfViewCustomConfig;

public class WfUserOpinionConvertor {
	public static WfUserOpinionForm convertVoToForm(WfUserOpinion entity) {
		if(entity != null) {
			WfUserOpinionForm form = new WfUserOpinionForm();
			form.setId(entity.getId());
			form.setOpinion(entity.getOpinion());
			form.setUserId(entity.getUserId());
			return form;
		}else
			return null;
	}
	
	public static void convertFormToVo(WfUserOpinionForm form, WfUserOpinion entity) {
		if(entity != null && form != null) {
			entity.setId(form.getId());
			if(form.getOpinion() != null && form.getOpinion().trim().length() > 0)
				entity.setOpinion(form.getOpinion().trim());
			if(form.getUserId() != null )
				entity.setUserId(form.getUserId());
			
			
		}
	}
	
	public static List<WfUserOpinionForm> convertVoListToFormList(List<WfUserOpinion> wfUserOpinionList) {
		if(wfUserOpinionList != null && wfUserOpinionList.size() > 0) {
			List<WfUserOpinionForm> wfUserOpinionFormList = new ArrayList();
			for(int i=0; i<wfUserOpinionList.size(); i++) {
				wfUserOpinionFormList.add(convertVoToForm(wfUserOpinionList.get(i)));
			}
			return wfUserOpinionFormList;
		}
		return null;
	}

	public static List<WfUserOpinion> convertFormListToVoList(List<WfUserOpinionForm> wfUserOpinionFormList) {
		if(wfUserOpinionFormList != null && wfUserOpinionFormList.size() > 0) {
			List<WfUserOpinion> wfUserOpinionList = new ArrayList();
			for(int i=0; i<wfUserOpinionFormList.size(); i++) {
				WfUserOpinion wfUserOpinion = new WfUserOpinion();
				convertFormToVo(wfUserOpinionFormList.get(i), wfUserOpinion);
				wfUserOpinionList.add(wfUserOpinion);
			}
			return wfUserOpinionList;
		}
		return null;
	}
}